﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using spbtzb;

public partial class MasterPage : System.Web.UI.MasterPage
{
    //protected string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='E://spbtzb.mdb';";
    protected string strConnection = spbtzb.ConString.ConnString;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindNav();
        }
    }
    protected void BindNav()
    {
        DataTable dt = AccessHelper.ExecuteDataTable(strConnection, CommandType.Text,
                             "SELECT ID, TypeCode, TypeName FROM ContentType WHERE ParentType = '" + Common.PARENT_CODE + "'");

        for (int i = 0; i < dt.Rows.Count; ++i)
        {
            string sqlCmd = String.Format("SELECT * FROM ContentType WHERE ParentType = '{0}' ORDER BY ID", dt.Rows[i]["TypeCode"].ToString());
            System.Data.DataTable dtChildTypes = AccessHelper.ExecuteDataTable(strConnection, System.Data.CommandType.Text, sqlCmd);

            for (int j = 0; j < dtChildTypes.Rows.Count; ++j)
            {
                string strSingle = dtChildTypes.Rows[j]["IsSingle"].ToString();
                if (strSingle == "1")
                {
                    dt.Rows[i]["TypeCode"] = ResolveUrl("~") + "ContentList.aspx?type=" + dtChildTypes.Rows[j]["TypeCode"].ToString();
                }
            }
        }
        rpNav.DataSource = dt;
        rpNav.DataBind();

    }
}
